package main

import (
	"database/sql"

	_ "github.com/lib/pq"
)

var db *sql.DB

func sqlOpen() {
	var err error
	db, err = sql.Open("postgres", "port=5432 user=postgres password=123456 dbname=productsmanagesslmode=disable")
	println("连接成功！")
	//sslmode就是安全验证模式;

	//或者这种方式打开
	//db, err := sql.Open("postgres", "postgres://pqgotest:postgres@localhost/pqgotest?sslmode=verify-full")
	if err != nil {
		panic(err)
	}
}

func main() {
	sqlOpen()
}
